package util;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryFactory;

public class QueryConverter {
	
	public String convertSelectToAsk(String selectQueryString){
		
		Query selectQuery = QueryFactory.create(selectQueryString);
		String askQueryString;
		
		String queryPattern = selectQuery.getQueryPattern().toString();
		
		//Building the ASK query
		askQueryString = "ASK \n";
		askQueryString += queryPattern;
		
		return askQueryString;
	}
	
	public static void main (String args[]){
		
		//Testing
		
		String selectQueryString = "PREFIX id:      <http://dotac.rkbexplorer.com/id/> " +
								   "PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#> "+
								   "PREFIX foaf:    <http://xmlns.com/foaf/0.1/> "+
									
								   "select ?nomeInstituicao ?telefone "+
								   "where "+
								   "{ "+
								   "id:org-anglia-ac-uk rdfs:label ?nomeInstituicao. "+
								   "id:org-anglia-ac-uk foaf:phone ?telefone. "+
								   "}";
		
		QueryConverter queryConverter = new QueryConverter();
		
		String askQueryString = queryConverter.convertSelectToAsk(selectQueryString);
		
		System.out.println(askQueryString);
											
	}

}
